package net.lab1024.sa.admin.module.business.yct.ycttzq.controller;

import net.lab1024.sa.admin.module.business.yct.ycttzq.domain.form.UserProfileAddForm;
import net.lab1024.sa.admin.module.business.yct.ycttzq.domain.form.UserProfileQueryForm;
import net.lab1024.sa.admin.module.business.yct.ycttzq.domain.form.UserProfileUpdateForm;
import net.lab1024.sa.admin.module.business.yct.ycttzq.domain.vo.UserProfileVO;
import net.lab1024.sa.admin.module.business.yct.ycttzq.service.UserProfileService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 听诊器用户成员 Controller
 *
 * @Author zhangben
 * @Date 2024-10-10 13:24:57
 * @Copyright 20241010
 */

@RestController
@Tag(name = "听诊器用户成员")
public class UserProfileController {

    @Resource
    private UserProfileService userProfileService;

    @Operation(summary = "分页查询 @author zhangben")
    @PostMapping("/userProfile/queryPage")
    @SaCheckPermission("userProfile:query")
    public ResponseDTO<PageResult<UserProfileVO>> queryPage(@RequestBody @Valid UserProfileQueryForm queryForm) {
        return ResponseDTO.ok(userProfileService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author zhangben")
    @PostMapping("/userProfile/add")
    @SaCheckPermission("userProfile:add")
    public ResponseDTO<String> add(@RequestBody @Valid UserProfileAddForm addForm) {
        return userProfileService.add(addForm);
    }

    @Operation(summary = "更新 @author zhangben")
    @PostMapping("/userProfile/update")
    @SaCheckPermission("userProfile:update")
    public ResponseDTO<String> update(@RequestBody @Valid UserProfileUpdateForm updateForm) {
        return userProfileService.update(updateForm);
    }


    @Operation(summary = "单个删除 @author zhangben")
    @GetMapping("/userProfile/delete/{id}")
    @SaCheckPermission("userProfile:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return userProfileService.delete(id);
    }
}
